package com.sun.entity.users;

import com.sun.entity.BaseEntity;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.SQLDelete;

import java.util.List;

/**
 * MP自动填充Handler
 *
 * @Author sun
 * @CreateTime 2025/9/2 01:56
 */

@Data
@Table(name = "roles")
@Entity
@SQLDelete(sql = "update roles set deleted = 1 where id = ?")
public class Role extends BaseEntity {
    @Id
    private Long id;
    @ManyToMany
    @JoinTable(name = "role_menus", joinColumns = @JoinColumn(name = "roleId"), inverseJoinColumns = @JoinColumn(name = "menuId"))
    private List<Menu> menus;

    @ManyToMany
    @JoinTable(name = "role_permissions", joinColumns = @JoinColumn(name = "roleId"), inverseJoinColumns = @JoinColumn(name = "permissionId"))
    private List<Permission> permissions;
}
